<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use App\Models\SShareLog;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;

class ShareLogController extends Controller {
	use HasResourceActions;

	/**
	 * Index interface.
	 *
	 * @param Content $content
	 * @return Content
	 */
	public function index(Content $content) {
		return $content
			->header('分享日志')
			->description('列表')
			->body($this->grid());
	}

	/**
	 * Show interface.
	 *
	 * @param mixed $id
	 * @param Content $content
	 * @return Content
	 */
	public function show($id, Content $content) {
		return $content
			->header('分享日志')
			->description('详情')
			->body($this->detail($id));
	}

	/**
	 * Edit interface.
	 *
	 * @param mixed $id
	 * @param Content $content
	 * @return Content
	 */
	public function edit($id, Content $content) {
		return $content
			->header('分享日志')
			->description('编辑')
			->body($this->form()->edit($id));
	}

	/**
	 * Create interface.
	 *
	 * @param Content $content
	 * @return Content
	 */
	public function create(Content $content) {
		return $content
			->header('分享日志')
			->description('新增')
			->body($this->form());
	}

	/**
	 * Make a grid builder.
	 *
	 * @return Grid
	 */
	protected function grid() {
		$grid = new Grid(new SShareLog);

		$grid->id('Id')->sortable();
		$grid->user()->name("学生姓名");
		$grid->cloudLesson()->title("课堂名称");
		// $grid->info_type('Info type');
		// $grid->shart_type('Shart type');
		$grid->created_at('分享时间');
		// $grid->updated_at('Updated at');
		$grid->disableActions();
		$grid->disableCreateButton();

		return $grid;
	}

	/**
	 * Make a show builder.
	 *
	 * @param mixed $id
	 * @return Show
	 */
	protected function detail($id) {
		$show = new Show(SShareLog::findOrFail($id));

		$show->id('Id');
		$show->user_id('User id');
		$show->info_id('Info id');
		$show->info_type('Info type');
		$show->shart_type('Shart type');
		$show->created_at('Created at');
		$show->updated_at('Updated at');

		return $show;
	}

	/**
	 * Make a form builder.
	 *
	 * @return Form
	 */
	protected function form() {
		$form = new Form(new SShareLog);

		$form->number('user_id', 'User id');
		$form->number('info_id', 'Info id');
		$form->number('info_type', 'Info type');
		$form->number('shart_type', 'Shart type');

		return $form;
	}
}
